<%--
  Created by IntelliJ IDEA.
  User: willy
  Date: 2022/4/6
  Time: 14:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>login</title>
</head>
<body>
<form action="loginController" method="post">
    <table>
        <tr>
            <td>用&nbsp&nbsp户:</td><td><input name="user" type="text" ></td>
        </tr>
        <tr>
            <td>密&nbsp&nbsp码:</td><td><input name="password" type="password"></td>
        </tr>
        <tr>
            <td>验证码:</td><td><input name="yanzheng" type="text" size="10"><b>8774</b></td>
        </tr>
        <tr>
            <td>所在学院:</td><td><select id="school"  name="school"  onfocus="f1()" onchange="f2()">
            <option value="0">---请选择---</option>
        </select></td>
        </tr>
        <tr>
            <td>所在系</td><td><select id="xi" name="xi" >
            <option value="0">---请选择---</option>
        </select></td>
        </tr>
    </table>
            <input name="登录" value="登录" type="submit">
            &nbsp&nbsp&nbsp&nbsp
            <a href="login.jsp">帮助</a>
            &nbsp&nbsp&nbsp&nbsp
            <a href="login.jsp">忘记密码</a>

</form>
</body>
<script type="text/javascript">
    let schoolList = ["计算机科学与工程学院", "电子工程与光电技术学院", "自动化学院"];
    let allxiList=[
                    ["计算机科学与技术","软件工程","智能科学与技术"],
                    ["电子信息工程","通信工程","电子科学与技术","光电信息科学与工程"],
                    ["电子工程及其自动化","智能电网信息工程","轨道交通信号与控制"]
                ];

    function f1(){
        let pro=document.getElementById("school");
        pro.length=schoolList.length+1;
        for(let i=1;i<pro.length;i++){
        pro[i].innerHTML=schoolList[i-1];
        pro[i].value=i;
        }
    }

    function f2(){
        let xi=document.getElementById("xi");
        let school=document.getElementById("school");
        xi.value=0;
        let xiList=allxiList[school.value-1];
        xi.length=xiList.length+1;
        for(let i=1; i<xi.length; i++){
            xi[i].innerText=xiList[i-1];
            xi[i].value=i;
        }
    }
</script>
</html>